package com.ardo.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.ardo.entity.ResponseResult;
import com.ardo.entity.mall.Notice;
import com.ardo.entity.vo.NoticeIndex;
import com.ardo.entity.vo.Query;
import com.ardo.mapper.NoticeMapper;
import com.ardo.service.NoticeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {

    @Resource
    private NoticeMapper noticeMapper;

    @Override
    public String queryNoticeList(Query query) {
        String result = "";
        List<Notice> noticeList = noticeMapper.queryNoticeList(query);
        if(noticeList!=null && noticeList.size()>0){
            NoticeIndex index = new NoticeIndex();
            index.setDataList(noticeList);
            index.setTotalPage(1);//多少页码
            index.setTotalRow(noticeList.size());
            result = JSONObject.toJSONString(ResponseResult.success(index));
        }
        return result;
    }

    @Override
    public String queryNoticeDetail(Integer id) {
        String result = "";
        Notice notice = noticeMapper.queryNoticeDetail(id);
        result = JSONObject.toJSONString(ResponseResult.success(notice));
        return result;
    }
}
